#!/bin/bash
#
#  nachocoind The NachoCoin Core server.
#
#
# chkconfig: 345 80 20
# description: nachocoind
# processname: nachocoind
#

# Source function library.
. /etc/init.d/functions

# you can override defaults in /etc/sysconfig/nachocoind, see below
if [ -f /etc/sysconfig/nachocoind ]; then
        . /etc/sysconfig/nachocoind
fi

RETVAL=0

prog=nachocoind
# you can override the lockfile via BITCOIND_LOCKFILE in /etc/sysconfig/nachocoind
lockfile=${BITCOIND_LOCKFILE-/var/lock/subsys/nachocoind}

# nachocoind defaults to /usr/bin/nachocoind, override with BITCOIND_BIN
nachocoind=${BITCOIND_BIN-/usr/bin/nachocoind}

# nachocoind opts default to -disablewallet, override with BITCOIND_OPTS
nachocoind_opts=${BITCOIND_OPTS--disablewallet}

start() {
    echo -n $"Starting $prog: "
    daemon $DAEMONOPTS $nachocoind $nachocoind_opts
    RETVAL=$?
    echo
    [ $RETVAL -eq 0 ] && touch $lockfile
    return $RETVAL
}

stop() {
    echo -n $"Stopping $prog: "
    killproc $prog
    RETVAL=$?
    echo
    [ $RETVAL -eq 0 ] && rm -f $lockfile
    return $RETVAL
}

case "$1" in
    start)
        start
        ;;
    stop)
        stop
        ;;
    status)
        status $prog
        ;;
    restart)
        stop
        start
        ;;
    *)
        echo "Usage: service $prog {start|stop|status|restart}"
        exit 1
        ;;
esac
